﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iOak.Business.Campaigns;

namespace iOak.Web
{
    public partial class ResumeList : System.Web.UI.Page
    {
        private static readonly ApplicationService itemApplicationService = new ApplicationService();
        private static readonly CampaignService itemCampaignService = new CampaignService();
        private WorkAssistant _workassistant = new WorkAssistant();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var listApp = itemApplicationService.GetListByCompanyId(_workassistant.CurrentUser.CompanyId);
                ddlName.Items.Add(new ListItem("", ""));
                listApp.ForEach(item =>
                    {
                        var itemCampaign = itemCampaignService.Retrieve(item.CampaignId);
                        if (itemCampaign != null)
                        {
                            ddlName.Items.Add(new ListItem(itemCampaign.Subject, item.ApplicationId.ToString()));
                        }
                    });

                Session.Remove("ApplicationId");
                htdGrid.BindData();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Session["ApplicationId"] = ddlName.SelectedValue;
            htdGrid.BindData(ddlName.SelectedValue, txtKey.Text.Trim());
        }
    }
}